from django.contrib import admin
from visitor.models import VisitorModel
from visitor.models import VisitorPerson
from visitor.models import VisitorCar
from visitor.models import VisitorApply
from visitor.models import VisitorApplyPerson
from visitor.models import VisitorApplyCar
from visitor.models import VisitorApplyVerify


@admin.register(VisitorModel)
class VisitorModelAdmin(admin.ModelAdmin):
    list_display = (
        "dept",
        "name",
        "phone",
    )
    list_filter = ("dept",)
    search_fields = ("name", "phone")
    autocomplete_fields = []


@admin.register(VisitorPerson)
class GuestVisitorAdmin(admin.ModelAdmin):
    list_display = ("visitor", "person", "updated")
    list_filter = ()
    search_fields = ("visitor__name", "visitor__phone")
    autocomplete_fields = ["visitor", "visitor"]


@admin.register(VisitorCar)
class VisitorCarAdmin(admin.ModelAdmin):
    list_display = ("visitor", "car", "updated")
    list_filter = ()
    search_fields = ("visitor__name", "visitor__phone")
    autocomplete_fields = ["visitor", "car"]


@admin.register(VisitorApply)
class VisitorApplyAdmin(admin.ModelAdmin):
    list_display = ("visitor", "status", "when", "isfree")
    list_filter = ("status",)
    search_fields = ("visitor__name", "visitor__phone")
    autocomplete_fields = [
        "visitor",
    ]


@admin.register(VisitorApplyPerson)
class VisitorApplyPersonAdmin(admin.ModelAdmin):
    list_display = ("apply", "person")
    list_filter = ("apply",)
    autocomplete_fields = ["apply","person",]


@admin.register(VisitorApplyCar)
class VisitorApplyCarAdmin(admin.ModelAdmin):
    list_display = ("apply", "car")
    list_filter = ("apply",)
    search_fields = ("apply__visitor__name", "apply__visitor__phone")
    autocomplete_fields = [
        "apply",
        "car",
    ]


@admin.register(VisitorApplyVerify)
class VisitorApplyVerifyAdmin(admin.ModelAdmin):
    list_display = (
        "apply",
        "stage",
        "status",
    )
    list_filter = (
        "stage",
        "status",
    )
    search_fields = ("apply__visitor__name", "apply__visitor__phone")
    autocomplete_fields = [
        "apply",
    ]
